package com.menghao.sso.server.util;

import com.menghao.sso.server.model.ticket.ServiceTicket;
import com.menghao.sso.server.model.ticket.TicketGrantingTicket;

import java.util.UUID;

/**
 * <p>票据Id生成工具类.<br>
 *
 * @author menghao.
 * @version 2017/11/17.
 */
public class TicketIdGenerator {

    public static String newTGTId() {
        return newTicketId(TicketGrantingTicket.PREFIX);
    }

    public static String newSTId() {
        return newTicketId(ServiceTicket.PREFIX);
    }

    private static String newTicketId(String prefix) {
        StringBuilder builder = new StringBuilder();
        builder.append(prefix);
        builder.append(UUID.randomUUID().toString().replaceAll("-", ""));
        return builder.toString();
    }
}
